.TH std::experimental::filesystem::current_path 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::experimental::filesystem::current_path \- std::experimental::filesystem::current_path

.SH Synopsis
   Defined in header <experimental/filesystem>
   path current_path();                                \fB(1)\fP (filesystem TS)
   path current_path( error_code& ec );                \fB(2)\fP (filesystem TS)
   void current_path( const path& p );                 \fB(3)\fP (filesystem TS)
   void current_path( const path& p, error_code& ec ); \fB(4)\fP (filesystem TS)

   Returns or changes the current path.

   1,2) Returns the absolute path of the current working directory, obtained as if by
   POSIX getcwd. \fB(2)\fP returns path() if error occurs.
   3,4) Changes the current working directory to p, as if by POSIX chdir.

.SH Parameters

   p  - path to change the current working directory to
   ec - out-parameter for error reporting in the non-throwing overloads

.SH Return value

   1,2) Returns the current working directory.
   3,4) \fI(none)\fP

.SH Exceptions

   1,2) The overload that does not take an error_code& parameter throws
   filesystem_error on underlying OS API errors, constructed with the OS error code as
   the error code argument. std::bad_alloc may be thrown if memory allocation fails.
   The overload taking an error_code& parameter sets it to the OS API error code if an
   OS API call fails, and executes ec.clear() if no errors occur. This overload has
   noexcept specification:
   noexcept

   3,4) The overload that does not take an error_code& parameter throws
   filesystem_error on underlying OS API errors, constructed with p as the first
   argument and the OS error code as the error code argument. std::bad_alloc may be
   thrown if memory allocation fails. The overload taking an error_code& parameter sets
   it to the OS API error code if an OS API call fails, and executes ec.clear() if no
   errors occur. This overload has
   noexcept specification:
   noexcept


.SH Notes

   The current working directory is the directory that is used as the starting location
   in path resolution for relative paths. Single current working directory is
   associated with entire process.

   The current working directory is a dangerous global state of the program. Behavior
   of various file input/output related functions are affected by the value of the
   current path. The current path may be unexpectedly changed by any component of the
   program, including various external libraries or other threads.

.SH See also

    This section is incomplete

.SH Categories:
     * Noindexed pages
     * unconditionally noexcept
     * Todo without reason
.SH Hidden categories:
     * Pages with unreviewed unconditional noexcept template
     * Pages with unreviewed noexcept template
